﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Project.Controller;
using Project.Model;
using Project.UserControls;

namespace Project.View
{
    public partial class Log : Form
    {
        private Spel spel;
        private Form form;
        private bool logOnly;

        public Log(Spel spel, Form form, bool logOnly)
        {
            InitializeComponent();
            this.Show();
            this.spel = spel;
            this.form = form;
            this.logOnly = logOnly;
            if (this.logOnly)
            {
                this.form.Visible = false;
            }
            else
            {
                this.start_button.Enabled = false;
            }
        }

        public void trace(string str)
        {
            log_RichTextBox.Text = str + "\n" + "---------------------\n" + log_RichTextBox.Text;
        }

        private void start_button_Click(object sender, EventArgs e)
        {
            this.spel.start();
            this.start_button.Enabled = false;
        }

        private void OnClose(object sender, FormClosingEventArgs e)
        {
            this.form.Visible = true;
            if (((GUI)this.form).ControlProperty is Spel_UserControl && logOnly)
            {
                ((GUI)this.form).toonMenu();
            }
        }

        public bool LogOnly
        {
            get { return logOnly; }
            set { logOnly = value; }
        }
    }
}
